/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package clienttestbytebuffer;

import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author ThanhTri
 */
public class ClientTestByteBuffer {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            // TODO code application logic here
            SocketChannel socket = SocketChannel.open();          
            socket.connect(new InetSocketAddress(InetAddress.getLocalHost(), 5000));
            
            ByteBuffer b = ByteBuffer.allocate(512);
            b.putInt(120);
            b.putInt(30);
            String s ="hello server";
            b.put(s.getBytes());
            b.flip();
            int numOfbyte = socket.write(b);
            System.out.println("Num Of Byte Send:"+numOfbyte);

        } catch (IOException ex) {
            Logger.getLogger(ClientTestByteBuffer.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}
